from django.conf.urls.defaults import patterns, url, include
from django.conf import settings
from views import user_login, user_logout

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',

     url(r'^$', 'filter.views.home', name='home'),

    # Uncomment the admin/doc line below to enable admin documentation:
    # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
    url(r'^admin/', include(admin.site.urls)),
    
    (r'^login/$', user_login),
    (r'^logout/$', user_logout),
    
    (r'^archiwum/$', 'archive.views.show_archive'),
    url (r'^archiwum/(?P<msgid>.*)$', 'archive.views.show_message', name='pokaz_wiadomosc'),
    
    url (r'^konfiguracja/$', 'configuration.views.show_options', name='opcje_konf'),
    url (r'^konfiguracja/ustal/$', 'configuration.views.show_options_form', name='ustal_opcje_konf'),
    (r'^konfiguracja/nowa/$', 'configuration.views.check_options_form'),
    
    url(r'^filtr/$', 'filtering.views.show_rules', name='filtr'),
    url(r'^filtr/regula(?P<tmp_ruleid>\d+)_(?P<ruleid>\d+)*/nowy_warunek$', 'filtering.views.add_new_condition', name='nowy_warunek'),
    url(r'^filtr/regula(?P<tmp_ruleid>\d+)_(?P<ruleid>\d+)*/dodaj_warunek$', 'filtering.views.add_condition_to_rule', name='dodaj_warunek_do_reguly'),
    
    url(r'^filtr/regula(?P<tmp_ruleid>\d+)_(?P<ruleid>\d+)*/dodaj_warunek/zalacznik$', 'filtering.views.add_condition_attachment_to_rule', name='dodaj_warunek_zalacznika'),
    url(r'^filtr/regula(?P<tmp_ruleid>\d+)_(?P<ruleid>\d+)*/dodaj_warunek/data$', 'filtering.views.add_condition_date_to_rule', name='dodaj_warunek_daty'),
    url(r'^filtr/regula(?P<tmp_ruleid>\d+)_(?P<ruleid>\d+)*/dodaj_warunek/nadawca$', 'filtering.views.add_condition_from_to_rule', name='dodaj_warunek_nadawcy'),
    url(r'^filtr/regula(?P<tmp_ruleid>\d+)_(?P<ruleid>\d+)*/dodaj_warunek/slowo_kluczowe$', 'filtering.views.add_condition_keyword_to_rule', name='dodaj_warunek_slowa'),
    url(r'^filtr/regula(?P<tmp_ruleid>\d+)_(?P<ruleid>\d+)*/dodaj_warunek/ilosc_zalacznikow$', 'filtering.views.add_condition_anr_to_rule', name='dodaj_warunek_ilosc_zalacznikow'),
    url(r'^filtr/regula(?P<tmp_ruleid>\d+)_(?P<ruleid>\d+)*/dodaj_warunek/przekierowanie$', 'filtering.views.add_condition_resent_to_rule', name='dodaj_warunek_odsylania'),
    url(r'^filtr/regula(?P<tmp_ruleid>\d+)_(?P<ruleid>\d+)*/dodaj_warunek/rozmiar$', 'filtering.views.add_condition_size_to_rule', name='dodaj_warunek_rozmiaru'),
    url(r'^filtr/regula(?P<tmp_ruleid>\d+)_(?P<ruleid>\d+)*/dodaj_warunek/temat$', 'filtering.views.add_condition_subject_to_rule', name='dodaj_warunek_tematu'),
    url(r'^filtr/regula(?P<tmp_ruleid>\d+)_(?P<ruleid>\d+)*/dodaj_warunek/odbiorca$', 'filtering.views.add_condition_to_to_rule', name='dodaj_warunek_odbiorcy'),
    
    url(r'^filtr/regula(?P<tmp_ruleid>\d+)/warunek(?P<condid>\d+)_(?P<ruleid>\d+)*/edytuj/$', 'filtering.views.edit_condition', name='edytuj_warunek'),
    url(r'^filtr/regula(?P<tmp_ruleid>\d+)/warunek(?P<ctype>\d+)_(?P<condid>\d*)_(?P<ruleid>\d+)*/zatwierdz$', 'filtering.views.confirm_condition', name='zatwierdz_warunek'),
    url(r'^filtr/regula(?P<tmp_ruleid>\d+)/warunek(?P<condid>\d+)_(?P<ruleid>\d+)*/usun$', 'filtering.views.delete_condition', name='usun_warunek'),
    
    url(r'^filtr/regula(?P<ruleid>\d+)/edytuj$', 'filtering.views.edit_rule', name='edytuj_regule'),
    url(r'^filtr/regula(?P<tmp_ruleid>\d+)_(?P<ruleid>\d+)*/zatwierdz$', 'filtering.views.confirm_rule', name='zatwierdz_regule'),
    url(r'^filtr/regula(?P<ruleid>\d+)/usun$', 'filtering.views.delete_rule', name='usun_regule'),
    url(r'^filtr/regula(?P<ruleid>\d+)$', 'filtering.views.show_rule', name='regula'),

    url(r'^uzytkownicy/$', 'users.views.show_users', name='uzytkownicy'),
    url(r'^uzytkownicy/nowy_uzytkownik$', 'users.views.create_new_user', name='nowy_uzytkownik'),
    url(r'^uzytkownicy/(?P<user_id>\d+)/zatwierdz$', 'users.views.check_user', name='zatwierdz_uzytkownika'),
    url(r'^uzytkownicy/(?P<user_id>\d+)/edytuj$', 'users.views.edit_user', name='edytuj_uzytkownika'),
    url(r'^uzytkownicy/(?P<user_id>\d+)/usun$', 'users.views.delete_user', name='usun_uzytkownika'),

    (r'^status/$', 'status.views.show_status'),
)

if settings.DEBUG:
    urlpatterns += patterns('',
        (r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}),
    )
